import { NestFactory } from '@nestjs/core';
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
import { AppModule } from './app.module';

async function bootstrap() {
  const { NODE_ENV, REDIS_PORT, REDIS_HOST } = process.env;
  console.log('Microservice listening on port:', Number(REDIS_PORT), NODE_ENV);
  const app = await NestFactory.createMicroservice<MicroserviceOptions>(
    AppModule,
    {
      transport: Transport.REDIS,
      options: {
        host: REDIS_HOST,
        port: Number(REDIS_PORT),
      },
    },
  );
  await app.listen();
}
bootstrap();
